package com.qinglei.recoup.longconn.dispatch.util;

import com.qinglei.recoup.common.utils.FileUtils;
import com.qinglei.recoup.longconn.constant.LongConnConstant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.File;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

@Component
public class RadarJsonUtil {

    //@Value("${dataPath}")
    private static String dataPath = "/opt/app/recoup/data/";

    private static String day_split_time = "08:30";            //早上切分时间点
    private static String night_split_time = "20:30";         //晚上切分时间点

    public static List<String> getAllTadayJson(){
        List<String> fileList = FileUtils.scanDirectory(dataPath);
        String localDate = LocalDate.now().minusDays(1l).toString().replace("-","");
        fileList.removeIf(f->{
            if(f.contains("Night/HealthCare/ResultData") && !f.contains("未知机构") && f.contains(localDate)){
                return  false;
            }else {
                return  true;
            }
        });
        return fileList;
    }

    /**
     * 检查是否是白天时段
     */
    private static boolean checkIsDay() {
        boolean isDay = false;
        LocalTime now = LocalTime.now();
        if (now.isAfter(LocalTime.parse(day_split_time)) && now.isBefore(LocalTime.parse(night_split_time))) {
                isDay = true;
        }

        return isDay;
    }
}
